<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			*{
				margin: 0;
				padding: 0;
			}
			ul,li{
				list-style: none;
			}
			a{
				text-decoration: none;
				color: white;
			}
			
			.list{
				position: relative;
				width: 200px;
				height: 150px;
				border: 1px solid black;
			}
			
			.list>li{
				width: 200px;
				height: 50px;
				background-color: hotpink;
				text-align: center;
				line-height: 50px;
			}
			
			
			.list>li:nth-child(2){
				border-top: 1px solid black;
				border-bottom: 1px solid black;
				box-sizing: border-box;
			}
			
			.list>li .listIn{
				position: absolute;
				left: 200px;
				top: -1px;
				width: 200px;
				height: 150px;
				border: 1px solid purple;
				display: none;
			}
			
			.list li .listIn li{
				width: 200px;
				height: 50px;
				background-color: skyblue;
			}
			.list li .listIn li:nth-child(2){
				border-top: 1px solid purple;
				border-bottom: 1px solid purple;
				box-sizing: border-box;
			}
			
			
		</style>
	</head>
	<body>
		<ul class="list">
			<li>
				<a href="javascript:;">家电</a>	
				<ul class="listIn">
					<li><a href="javascript:;">电视</a></li>
					<li><a href="javascript:;">冰箱</a></li>
					<li><a href="javascript:;">洗衣机</a></li>
				</ul>
			</li>
			
			<li>
				<a href="javascript:;">衣服</a>	
				<ul class="listIn">
					<li><a href="javascript:;">男装</a></li>
					<li><a href="javascript:;">女装</a></li>
					<li><a href="javascript:;">童装</a></li>
				</ul>
			</li>
			
			<li>
				<a href="javascript:;">数码</a>	
				<ul class="listIn">
					<li><a href="javascript:;">照相机</a></li>
					<li><a href="javascript:;">笔记本</a></li>
					<li><a href="javascript:;">手机</a></li>
				</ul>
			</li>
		</ul>
		
		
		<script type="text/javascript">
			var li_list = document.querySelectorAll('.list > li');

            var ul_list = document.querySelectorAll('.listIn');

            for(var i = 0; i < li_list.length; i++){

                li_list[i].index = i;

                li_list[i].onmouseenter = function(){
                    ul_list[this.index].style.display = 'block';
                }

                li_list[i].onmouseleave = function(){
                    ul_list[this.index].style.display = 'none';
                    ul_list[this.index].style.display = '';
                }
            }
		</script>
	</body>
</html>